package servlet;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.FileInputStream;
import java.io.IOException;

@WebServlet(name = "Servlet10", value = "/getImage")
public class Servlet10 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String path="D:\\javaweb-repo\\javaweb-repo\\web02\\src\\main\\webapp\\images\\lanhua.png";
        FileInputStream fis = new FileInputStream(path);
        ServletOutputStream os = response.getOutputStream();//图片的输出流
        byte [] buff = new byte[1024];
        int len=0;
        while (fis.read(buff)!=-1){
            os.write(buff);

        }
        fis.close();





    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
